﻿<UserControl x:Class="AppFabric.Admin.Clients.Desktop.UserControls.StatisticsUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:oxy="http://oxyplot.codeplex.com"
             xmlns:oxymodel="clr-namespace:OxyPlot;assembly=OxyPlot"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
    <UserControl.Resources>
        <DataTemplate x:Key="StatsTemplate" DataType="{x:Type oxymodel:PlotModel}">
            <oxy:Plot Model="{Binding}" MinHeight="300" MinWidth="600"/>
        </DataTemplate>
    </UserControl.Resources>

    <Grid>
        <ListView ItemsSource="{Binding Statistics, Mode=OneWay}" ItemTemplate="{StaticResource StatsTemplate}">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Width="{Binding (FrameworkElement.ActualWidth), RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}" 
                                   ItemWidth="{Binding (ListView.View).ItemWidth, RelativeSource={RelativeSource AncestorType=ListView}}" 
                                   MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}" 
                                   ItemHeight="{Binding (ListView.View).ItemHeight, RelativeSource={RelativeSource AncestorType=ListView}}" />
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>
    </Grid>
</UserControl>
